<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function doPage(pageNo) {
            document.forms[0].pageNum.value = pageNo;
            document.forms[0].submit();
        }
    </script>
</head>
<body>
<h1>用户列表</h1>
<a th:href="@{/users/toAdd}">添加</a>
<form th:action="@{/users}">
    <input type="hidden" name="pageNum">
    昵称：<input name="realName" th:value="${user.realName}">
    <input type="submit" value="查询">
<table>
    <tr style="background-color: darkgray">
        <td>ID</td>
        <td>账号</td>
        <td>昵称</td>
        <td>生日</td>
        <td>操作</td>
    </tr>
    <tr th:each="item, status:${page.list}" th:style="${status.count % 2 ==0 ? 'background-color:red;' : '' }">
        <td th:text="${item.id}">ID</td>
        <td th:text="${item.account}">账号</td>
        <td th:text="${item.realName}">昵称</td>
        <td th:text="${#dates.format(item.birthday, 'yyyy-MM-dd')}">生日</td>
        <td>
            <a th:href="@{/users/del(id=${item.id}, account=${item.account})}">删除</a>
        </td>
    </tr>
</table>
<div>
    当前<span th:text="${page.pageNum}">1</span>页，共<span th:text="${page.total}">10</span>条，共<span th:text="${page.pages}">5</span>页，每页<span th:text="${page.pageSize}">2</span>条
</div>
<div>
    <a href="javascript:void(0)" th:onclick="doPage(1)">首页</a>
    <a href="javascript:void(0)" th:onclick="doPage([[${page.pageNum - 1}]])">上页</a>
    <a href="javascript:void(0)" th:onclick="doPage([[${page.pageNum + 1}]])">下页</a>
    <a href="javascript:void(0)" th:onclick="doPage([[${page.pages}]])">尾页</a>
</div>
</form>
</body>
</html>